# 用户数据库
db = [
    ["admin","123456",1], # 1代表管理员
    ["lisi","123456",0] # 0 代表普通用户
]
# 家庭记录账单
finance = [
    ["吃饭支出","交通银行",247.8,"2016-03-12","家庭聚餐"],
    ["工资收入","现金",12345.0,"2016-03-15","开工资了"],
    ["服装支出","现金",1200.0,"2016-04-16","买衣服"],
    ["股票支出","工商银行",4500.36,"2017-05-06","股票大涨，买买买"],
]
acc_type = -1  # -1用户类型为空
linshi = []
# 记录登陆状态
login_count = 0
login_status = False # False 表示未登陆
while True:
    account = None
    password = None
    login_count += 1
    if login_count<4:
        account = None
        password = None

        print("欢迎来到 House  Wife 家庭记账通系统".center(50, "-"))
        account = input("请输入登陆账号名：")
        password = input("请输入登陆密码：")


        for i in db:
            if i[0] == account  and i[1] == password:
                # 继续判断用户类型
                acc_type = i[2]
                login_status = True
                break
            else:
                print("对不起，你的账户名或者密码错误,请重新输入！")
                break

        # if acc_type == -1:
        #     print("对不起，你的账户名或者密码错误,请重新输入！")
        #     login_status = False
        #     continue

        # login_status = True



    # else:print("输错3次了，白白")
        while login_status == True:
            print("登陆成功！欢迎来到系统！")
            login_count = 0
            if acc_type == 1:
                print("1.添加账务   2.编辑账务      3.删除账务      4.查询账务      5.退出系统")
                chose = input(">>>:")
                chose = int(chose)
                if chose == 1:
                    for data in range(0,5):
                        data = input("输入 类别 账户 金额 时间 说明：")
                        linshi.append(data)
                    print(linshi)
                    finance.append(linshi)

                elif chose == 2:
                    linshi.clear()
                    xu = input("输入修改的序号")
                    xu = int(xu)
                    for data in range(0,5):
                        data = input("输入 类别 账户 金额 时间 说明：")
                        linshi.append(data)
                    print(linshi)
                    finance[xu] = linshi
                elif chose == 3:
                    xu = input("输入删除的序号")
                    xu = int(xu)
                    del finance[xu]
                    print("删除成功")
                elif chose == 4:
                    print("类别    账户    金额   时间   说明")
                    print("".center(50, "-"))
                    for i, v in enumerate(finance):
                        print(i, end="\t\t")
                        for value in v:
                            print(value, end="\t")
                        print()
                    print("".center(50, "-"))
                elif chose == 5:
                    login_status = False
                    break
                else:print("输入错误")






            elif acc_type == 0:
                print("1.查询所有   2.按条件查询   3.退出登录")
                chose = input(">>>:")
                if chose == "1":
                    print("类别    账户    金额   时间   说明")
                    print("".center(50,"-"))
                    for i,v in enumerate(finance):
                        print(i,end="\t\t")
                        for value in v:
                            print(value,end="\t")
                        print()
                    print("".center(50,"-"))
                    continue
                elif chose == "2":
                    print("1.ID     2.类别    3.账户    4.金额    5.时间")
                    ch = []
                    find = input("请输入你要查询的条件：")
                    # 判断输入条件然后进行查询遍历
                    if find == "1":
                        dt = input("输入ID")
                        dt = int(dt)
                        print(finance[dt])
                    elif find == "2":
                        dt = input("输入类别")
                        for i in enumerate(finance):
                            if dt == i[1][0]:
                                print(i[1])
                    elif find == "3":
                        dt = input("输入账户")
                        for i in enumerate(finance):
                            if dt == i[1][1]:
                                print(i[1])
                    elif find == "4":
                        dt1 = input("输入最小金额")
                        dt1 = int(dt1)
                        dt2 = input("输入最大金额")
                        dt2 = int(dt2)
                        for i in enumerate(finance):
                            i[1][2] = int(i[1][2])
                            if dt1 <= i[1][2] and dt2 >= i[1][2]:
                                print(i[1])
                    elif find == "5":
                        dt = input("输入时间")
                        for i in enumerate(finance):
                            if dt == i[1][3]:
                                print(i[1])
                elif chose == "3":
                    login_status = False
                    break
                else:print("输入错误")

    else:
        print("输错3次了，白白")
        break